import React, { Component } from 'react'
import './style.css'
import { Divider } from 'antd';
const moment = require('moment');
require('moment/locale/zh-cn');

export default class Footer extends Component {

    state = {
        time: new Date()
    }

    componentDidMount() {
        this.interval = setInterval(() => {
            this.setState({ time: new Date() })
        }, 1000)
    }

    componentWillUnmount() {
        // 在组件卸载时清除定时器，防止内存泄漏
        clearInterval(this.interval);
    }

    render() {
        return (
            <Divider plain>
                {moment(this.state.time).local().format('YYYY年MM月DD日 ddd HH:mm:ss')}
            </Divider>
        )
    }
}
